﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CvModel;
using System.Data.Entity.Migrations;
using System.Data.SqlClient;
using System.Data;

namespace DAL
{
    public class WorkApplicationsDB
    {
        private static CvModelContainer _context = new CvModelContainer();

        public static void CreateWorkApplication(WorkApplications workApplication)
        {
            try
            {
                var query = _context.WorkApplications.Add(workApplication);

                _context.SaveChanges();
            }
            catch (Exception)
            {

                throw;
            }
        }

        //READ
        public static List<WorkApplications> GetAllWorkApplicationsFromApplicant(int applicantId)
        {
            try
            {
                return _context.WorkApplications.Where(w => w.ApplicantId == applicantId).ToList();
            }
            catch (Exception)
            {

                throw;
            }
        }
        //UPDATE
        //public static int UpdateWorkApplication(WorkApplications workApplication)
        //{
        //    try
        //    {
        //        _context.WorkApplications.AddOrUpdate(workApplication);
        //        return _context.SaveChanges();
        //    }
        //    catch (Exception)
        //    {

        //        throw;
        //    }
        //}
        //DELETE
        //public static int DeleteWorkApplication(int workApplicationId)
        //{
        //    try
        //    {
        //        var query =
        //            (from w in _context.WorkApplications
        //             where w.WorkApplicationId == workApplicationId
        //             select w).Single();

        //        _context.WorkApplications.Remove(query);

        //        return _context.SaveChanges();
        //    }
        //    catch (Exception)
        //    {
        //        throw;
        //    }
        //}
    }
}
